﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using VK.Comm;
using System.Web.UI.WebControls;

namespace VK.Casemeet
{
    public static class PageHelper
    {
        public static string GetSelectTrClass(int selectID)
        {
            string className = string.Empty;

            if (Util.GetQueryInt("selectID") == selectID)
            {
                return "select";
            }
            else
            {
                return className;
            }
        }

        public static string GetImageUrl(string url, string prefix)
        {
            string result = string.Empty;
            if (url == "Null.jpg")
            {
                result = url;
            }
            else
            {
                string[] urls = url.Split(new char[1] { '/' }, StringSplitOptions.RemoveEmptyEntries);
                for (int n = 0; n < urls.Length; n++)
                {
                    if (n == urls.Length - 1)
                    {
                        result += prefix + urls[n];
                    }
                    else
                    {
                        result += urls[n] + "/";
                    }
                }
            }
            return result;
        }

        public static void LoadSelectedCHK(CheckBoxList control, string value)
        {
            for (int i = 0; i < control.Items.Count; i++)
            {
                if (control.Items[i].Value == value)
                {
                    control.Items[i].Selected = true;
                }
            }
        }

        public static string GetIsEnableLabel(bool isEnable)
        {
            string result = string.Empty;
            if (isEnable)
            {
                result = "启用";
            }
            else
            {
                result = "停用";
            }
            return result;
        }

        public static string GetAreaName(string provinceName, string cityName)
        {
            string areaName = provinceName;
            if (!string.IsNullOrEmpty(cityName))
            {
                areaName = cityName;
            }

            return areaName;
        }
    }
}
